package cn.foolishbird.crow.sequence;


import cn.foolishbird.crow.core.util.DateTimeEnum;
import cn.foolishbird.crow.core.util.DateTimeUtils;
import cn.foolishbird.crow.core.util.RandomUtils;
import cn.foolishbird.crow.core.CrowEnum;

import java.time.LocalDateTime;

/**
 * @author foolishbird
 * @version 1.0
 */
public class TimePlusRandomPrefixSequenceStrategy extends AbstractPrefixSequenceStrategy {

    /**
     * 随机字符串
     */
    private int randomNum = 6;

    public TimePlusRandomPrefixSequenceStrategy(int randomNum, Enum<? extends CrowEnum> identity) {
        super(identity);
        this.randomNum = randomNum;
    }

    public TimePlusRandomPrefixSequenceStrategy(Enum<? extends CrowEnum> identity, int randomNum) {
        super(identity);
        this.randomNum = randomNum;
    }

    @Override
    protected String doCreateSequence() {
        return DateTimeUtils.format(LocalDateTime.now(), DateTimeEnum.SIMPLE_DATE_TIME) +
                RandomUtils.createRandomNum(this.randomNum);
    }

}
